package com.iwop.moto.service.impl;

import com.iwop.moto.model.SuperRecordModel;
import com.iwop.moto.service.BaseService;
import com.iwop.moto.service.MCouponService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by mobom on 2016/11/3.
 */
@Service
public class MCouponServiceImpl extends BaseService implements MCouponService {
    @Override
    public void addCoupon(SuperRecordModel superRecordModel) {
        getSqlSession().insert("MCouponMappper.insert",superRecordModel);
    }

    @Override
    public List<SuperRecordModel> getUserCouponBy(SuperRecordModel srm) {
        return  getSqlSession().selectList("MCouponMappper.getUserCoupon",srm);
    }

    @Override
    public List<SuperRecordModel> getUserCouponByParameter(SuperRecordModel srm) {
        return  getSqlSession().selectList("MCouponMappper.getUserCouponByParameter",srm);
    }

    @Override
    public void updateUserCoupon(SuperRecordModel srm) {
        getSqlSession().update("MCouponMappper.updateUserCoupon", srm);
    }
    @Override
    public void updateUserCouponStatusBySid(SuperRecordModel srm) {
        getSqlSession().update("MCouponMappper.updateUserCouponStatusBySid", srm);
    }

    @Override
    public SuperRecordModel countUserCoupon(String session_id) {
        return  getSqlSession().selectOne("MCouponMappper.countUserCoupon", session_id);
    }

    @Override
    public SuperRecordModel getUserCouponByCouponIdAndUserId(SuperRecordModel srmParams) {
        return  getSqlSession().selectOne("MCouponMappper.getUserCouponByCouponIdAndUserId", srmParams);
    }
 @Override
    public SuperRecordModel getUserCouponByCouponSid(SuperRecordModel srmParams) {
        return  getSqlSession().selectOne("MCouponMappper.getUserCouponByCouponSid", srmParams);
    }

    @Override
    public SuperRecordModel getCouponById(SuperRecordModel srmParams) {
        return  getSqlSession().selectOne("MCouponMappper.getCouponModelBySid", srmParams);
    }

    @Override
    public SuperRecordModel getUserCouPonBySid(String sid) {
        return  getSqlSession().selectOne("MCouponMappper.getUserCouponByCouponSid2", sid);
    }

    @Override
    public SuperRecordModel findUserCouponBySidAndUserId(SuperRecordModel superRecordModel) {
        return  getSqlSession().selectOne("MCouponMappper.findUserCouponBySidAndUserId", superRecordModel);
    }

    @Override
    public Integer fingUserCouponCountByStatus(SuperRecordModel superRecordModel) {
        return  getSqlSession().selectOne("MCouponMappper.fingUserCouponCountByStatus", superRecordModel);

    }


}
